﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Indigo = System.ServiceModel.Description;

namespace Microsoft.Cryptography.WCF
{
    /// <summary>
    /// Enables the user to configure client and service credentials as well as service credential authentication 
    /// settings for use on the client side of communication. This implementation extends the base class 
    /// (<see cref="System.ServiceModel.Description.ClientCredentials"/>) to support RSA-Signatures with SHA-2 
    /// encryption in XML-Signatures by returning an instance of 
    /// <see cref="Microsoft.Cryptography.WCF.ClientCredentialsSecurityTokenManager"/> instead  of 
    /// <see cref="System.ServiceModel.ClientCredentialsSecurityTokenManager"/> when calling the method 
    /// CreateSecurityTokenManager
    /// </summary>
    public class ClientCredentials : Indigo.ClientCredentials
    {
        /// <summary>
        /// Enables the user to configure client and service credentials as well as service credential authentication 
        /// settings for use on the client side of communication. This implementation extends the base class 
        /// (<see cref="System.ServiceModel.Description.ClientCredentials"/>) to support RSA-Signatures with SHA-2 
        /// encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ClientCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.ClientCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager
        /// </summary>
        public ClientCredentials()
            : base()
        {
        }

        /// <summary>
        /// Enables the user to configure client and service credentials as well as service credential authentication 
        /// settings for use on the client side of communication. This implementation extends the base class 
        /// (<see cref="System.ServiceModel.Description.ClientCredentials"/>) to support RSA-Signatures with SHA-2 
        /// encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ClientCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.ClientCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager
        /// </summary>
        /// <param name="other">A <see cref="System.ServiceModel.Description.ClientCredentials"/>. 
        /// All properties of the newly-constructed instance are reflecting the values of this parameter.</param>
        public ClientCredentials(Indigo.ClientCredentials other)
            : base(other)
        {
        }

        /// <summary>
        /// Creates a new copy of this <see cref="Microsoft.Cryptography.WCF.ClientCredentials"/> instance.
        /// </summary>
        /// <returns>Returns a new copy of this <see cref="Microsoft.Cryptography.WCF.ClientCredentials"/> instance.</returns>
        protected override System.ServiceModel.Description.ClientCredentials CloneCore()
        {
            return new ClientCredentials(this);
        }

        /// <summary>
        /// Creates a security token manager for this instance.This method is rarely called explicitly; it is primarily used 
        /// in extensibility scenarios and is called by the system itself. This implementation This implementation extends 
        /// the base class (<see cref="System.ServiceModel.Description.ClientCredentials"/>) to support RSA-Signatures 
        /// with SHA-2 encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ClientCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.ClientCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager
        /// </summary>
        /// <returns>Returns a security token manager for this instance.This method is rarely called explicitly; it is primarily used 
        /// in extensibility scenarios and is called by the system itself. This implementation This implementation extends 
        /// the base class (<see cref="System.ServiceModel.Description.ClientCredentials"/>) to support RSA-Signatures 
        /// with SHA-2 encryption in XML-Signatures by returning an instance of 
        /// <see cref="Microsoft.Cryptography.WCF.ClientCredentialsSecurityTokenManager"/> instead  of 
        /// <see cref="System.ServiceModel.ClientCredentialsSecurityTokenManager"/> when calling the method 
        /// CreateSecurityTokenManager</returns>
        public override System.IdentityModel.Selectors.SecurityTokenManager CreateSecurityTokenManager()
        {
            return new ClientCredentialsSecurityTokenManager(this);
        }
    }
}
